package com.atguigu03.list.exer2;

import java.util.ArrayList;
import java.util.List;

public class ListTest {

    public static void main(String[] args) {

        ArrayList list = new ArrayList<>();

        for (int i = 0; i < 30; i++) {

            int v = (int)(Math.random() * (122 - 97 + 1)) + 97;
            list.add((char)v + "");
        }

        System.out.println(list);
        System.out.println(listTest(list, "a"));
    }

    public static int listTest(List list,String s) {

        int count = 0;
        for (Object o : list) {
            if(o.equals(s)) {
                count++;
            }
        }
        return count;

    }
}
